<?php
/**
 * Created by PhpStorm.
 * User: dt
 * Time: 16:53
 */
namespace novel\base;

use common\base\BController;
use YII;

/**
 * 控制器基类
 * @package app\base
 */
class BaseController extends BController
{
    //存储request请求体
    public $body = [];
    //存储data
    public $data = [];
    public function beforeAction($action){
        $this->enableCsrfValidation=false;
        parent::body();
        $this->saveUserIp(2);
        return true;
    }

    /**
     * 设置全局视图参数
     */
    protected function setViewParams($title,$keyword,$desc)
    {
        if(Yii::$app->request->isAjax){
            return true;
        }
        $this->view->title = str_replace('*',$title,'*小说,*[TXT小说下载] - 华文轩小说网');
        $keywords = str_replace('*',$keyword,'华文轩*小说,*[TXT小说下载] - 华文轩小说网');
        $description = str_replace('*',$desc,'华文轩*小说,*[TXT小说下载] - 华文轩小说网');
        $this->view->params['keywords'] = $keywords;
        $this->view->params['description'] = $description;
    }
}